'''
Created on 29/03/2014

@author: juampi
'''
import unittest
import tablature
import chordinstrument
from chordinstrument import Position

class Test(unittest.TestCase):

    def test_empty_tab(self):
        tab = tablature.Tab(chordinstrument.Charango(),72,[]).render()
        expected_tab = """
E (5)|------------------------------------------------------------------------|
A (4)|------------------------------------------------------------------------|
E (4)|------------------------------------------------------------------------|
C (5)|------------------------------------------------------------------------|
G (4)|------------------------------------------------------------------------|
"""
        self.assertEquals(tab,expected_tab,"Expected tab doesn't match")
        
        tab = tablature.Tab(chordinstrument.Guitarra(),72,[]).render()        
        expected_tab = """
E (4)|------------------------------------------------------------------------|
B (3)|------------------------------------------------------------------------|
G (3)|------------------------------------------------------------------------|
D (3)|------------------------------------------------------------------------|
A (2)|------------------------------------------------------------------------|
E (2)|------------------------------------------------------------------------|
"""
        self.assertEquals(tab,expected_tab,"Expected tab doesn't match")

    def test_positions_in_tab(self):
        chords = [
             tablature.Chords(2,Position(0,0)),
             tablature.Chords(6,Position(0,0)),
             tablature.Chords(10,Position(0,0)),
             tablature.Chords(18,Position(0,0)),
             tablature.Chords(22,Position(0,3)),
             ]                    
        
        tab = tablature.Tab(chordinstrument.Charango(),72,chords).render()        
        expected_tab = """
E (5)|--0---0---0-------0---3-------------------------------------------------|
A (4)|------------------------------------------------------------------------|
E (4)|------------------------------------------------------------------------|
C (5)|------------------------------------------------------------------------|
G (4)|------------------------------------------------------------------------|
"""
        self.assertEquals(tab,expected_tab,"Expected tab doesn't match")


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.test_empty_tab']
    unittest.main()